package cn.iocoder.yudao.module.member.api.user;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.api.user.dto.UserRelationDTO;
import cn.iocoder.yudao.module.member.dal.dataobject.userrelation.UserRelationDO;
import cn.iocoder.yudao.module.member.dal.mysql.userrelation.UserRelationMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.w3c.dom.stylesheets.LinkStyle;

import javax.annotation.Resource;
import java.util.List;

@Service
@Validated
public class UserRelationApiImpl implements UserRelationApi{

    @Resource
    private UserRelationMapper userRelationMapper;

    @Override
    public UserRelationDTO getUserRelationOne(Long crmMemberUserId) {
        LambdaQueryWrapperX<UserRelationDO> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.eq(UserRelationDO::getCrmMemberUserId,crmMemberUserId);
        queryWrapper.eq(UserRelationDO::getStatus,0);
        queryWrapper.eq(UserRelationDO::getRelation,0);
        return BeanUtils.toBean(userRelationMapper.selectOne(queryWrapper),UserRelationDTO.class);
    }


    @Override
    public List<UserRelationDTO> getUserRelationList(Long crmMemberUserId) {
        LambdaQueryWrapperX<UserRelationDO> queryWrapper = new LambdaQueryWrapperX<>();
        queryWrapper.eq(UserRelationDO::getCrmMemberUserId,crmMemberUserId);
        queryWrapper.eq(UserRelationDO::getStatus,0);
        return BeanUtils.toBean(userRelationMapper.selectList(queryWrapper),UserRelationDTO.class);
    }
}
